package com.osce.common.config;

import cn.hutool.log.Log;
import cn.hutool.log.LogFactory;
import com.doudou.arc.ArcFaceEngine;
import com.doudou.minio.Minio;
import com.osce.common.constant.AppValues;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.annotation.Resource;

/**
 * @author zzxjs
 * @since 2023/7/31
 */
@Configuration
public class BeanConfig {
    private static final Log log = LogFactory.get(BeanConfig.class);

    @Resource AppValues appValues;

    @Bean
    public Minio minio() {
        try{
            return Minio.builder().endpoint(appValues.minio_endpoint).seeEndpoint(appValues.minio_seeendpoint).accessKey(appValues.minio_accessKey).secretKey(appValues.minio_secretKey).bucketName(appValues.minio_bucketName).build();
        }catch (Exception e){
            log.error(e);
            return null;
        }
    }


    @Bean
    public ArcFaceEngine arcFaceEngine() {
        try{
            return new ArcFaceEngine(appValues.arcface_appId, appValues.arcface_secret, appValues.arcface_active, appValues.library_path);
        }catch (Exception e){
            log.error(e);
            return null;
        }
    }
}
